package api

import (
	"github.com/gin-gonic/gin"
	"github.com/share309/gojwt"
	"rabbit/api/handler"
	"rabbit/api/middleware"
	"rabbit/consts"
)

func LoadRouters(r *gin.Engine) {
	r.Use(middleware.Cors())

	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
			user.POST("/sendMessage", handler.SendMessage)
		}
		chat := api.Group("/chat")
		{
			chat.Use(gojwt.JWTAuth(consts.Jwt_KEY))
			chat.GET("/ws", handler.Chat)
			chat.GET("/history", handler.History)
		}
	}
}
